package com.zhentao.controller;

import com.zhentao.file.service.impl.FileStorageServiceImpl;
import com.zhentao.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

@RestController
@RequestMapping("/minio")
public class MinioTestController {
    @Autowired
    private FileStorageServiceImpl fileStorageService;

    @RequestMapping("/uploadHtml")
    public ResponseResult uplaodHtml() throws FileNotFoundException {

        FileInputStream inputStream=new FileInputStream("D:\\考试壁纸.png");

        try {
            String url =fileStorageService.uploadHtmlFile("考试壁纸.png",inputStream);
            return ResponseResult.okResult(url);
        } catch (Exception e){
            return ResponseResult.errorResult(303,"minio异常");
        }
    }
}
